package com.tencent.welink.api.space.alarm;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.tencent.welink.api.OpenApiTokenChange;
import com.tencent.welink.api.base.WelinkOpenApi;
import com.tencent.welink.config.BussinessConfig;
import com.tencent.welink.util.CrontabUtil;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

/**
 * @Description: 7. 批量添加告警处理记录
 * @Author: limye
 * @CreateDate: 2020-6-15
 * @Version: V1.0
 */
public class AddProcessRecord extends WelinkOpenApi {

    private static final Logger log = LogManager.getLogger(AddProcessRecord.class);

    public AddProcessRecord(){
        super("/space/datahub/alarm/v0.1/addProcessRecord",false);
    }


    @Override
    public void displayResult(String result) {
    }


    public static void main(String[] args) {
        new BussinessConfig();
        CrontabUtil.addTaskInRate(new OpenApiTokenChange(), BussinessConfig.loginDurationMinutes,true);

        //实例化对象
        AddProcessRecord instance = new AddProcessRecord();

        /**
         * [
         *   {
         *     "warningId": "3456",
         *     "dealTime": 1556708722342,
         *     "dealManager": "haiboliu",
         *     "dealType": "重启",
         *     "dealDesc": "重启修复",
         *     "appendixFileId": "abcdefg",
         *     "isValid": 0
         *   },
         *   {
         *     "warningId": "4589",
         *     "dealTime": 1556708722355,
         *     "dealManager": "haiboliu",
         *     "dealType": "重启",
         *     "dealDesc": "重启修复",
         *     "appendixFileId": "cdefeee",
         *     "isValid": 0
         *   }
         * ]
         */
        //添加参数

        JSONArray jsonArr = new JSONArray();
        JSONObject paramJson1 = new JSONObject();
        paramJson1.put("warningId","3456");
        paramJson1.put("dealTime",1556708722342L);
        paramJson1.put("dealManager","haiboliu");
        paramJson1.put("dealType","重启");
        paramJson1.put("dealDesc","重启修复");
        paramJson1.put("appendixFileId","abcdefg");
        paramJson1.put("isValid",0);
        jsonArr.add(paramJson1);

        JSONObject paramJson2 = new JSONObject();
        paramJson2.put("warningId","4589");
        paramJson2.put("dealTime",1556708722355L);
        paramJson2.put("dealManager","haiboliu");
        paramJson2.put("dealType","重启");
        paramJson2.put("dealDesc","重启修复");
        paramJson2.put("appendixFileId","cdefeee");
        paramJson2.put("isValid",0);
        jsonArr.add(paramJson2);

        instance.getBodyPara().put("",jsonArr);

        //执行HTTP请求及展示结果
        instance.DoHttp();
        CrontabUtil.shutdown();

    }
}
